<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://doc.hyperf.io
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf-cloud/hyperf/blob/master/LICENSE
 */

namespace App\Controller;

use App\Exception\AppNotFoundException;
use App\Model\News;
use Hyperf\HttpServer\Annotation\AutoController;


/**
 * Class NewsController
 * @package App\Controller
 * @AutoController()
 */

class NewsController extends AbstractController
{
    public function index()
    {

       return $this->view->render('index');


    }

    public function category()
    {
        return $this->view->render('category');
    }

    public function detail()
    {
        $id = $this->request->input('id',0);
        $info = News::query()->with(['member'])->where('status',2)->find($id);

        if(empty($info))  throw new AppNotFoundException("找不到该资讯");

        return $this->view->render('detail',compact('info'));
    }
}
